<?php
class Zend_View_Helper_TextFormat
{
	public $view;

	public function setView(Zend_View_Interface $view)
	{
		$this->view = $view;
	}

	public function textFormat($content, $nl2br = true)
	{
		$content = $this->noId($content);
		return $this->text2html($content, $nl2br);
	}
	protected function noId($content)
	{
		return preg_replace('/\$Id:(.*?)\$/', "\$Id:\$", $content);
	}
	protected function text2html($content, $nl2br = true)
	{
		$content = htmlentities($content, null, 'UTF-8');
		$content = str_replace("\t", str_repeat('&nbsp;', 4), $content);
		$content = str_replace(" ", '&nbsp;', $content);
		if($nl2br)
		{
			$content = str_replace("\n", "<br />\n", $content);
		}
		return $content;
	}
}
